package com.dopplr.api
{
    public class City
    {
        //
        // calculated...
        //        

        /** all the trips to this city that we know about */
        public var trips:Array = [];

        //
        // from the API...
        //
        
        /** from country_code in the xml, e.g. NL */
        public var countryCode:String;
        /** from name in the xml, e.g. Amsterdam */
        public var name:String;
        /** north-south location e.g. 52.35 */
        public var latitude:Number;
        /** east-west location e.g. 4.91667 */
        public var longitude:Number;
        /** Dopplr page, e.g. http://www.dopplr.com/place/nl/amsterdam */
        public var url:String;
        /** geonames.org identifier, e.g. 2759794 */
        public var geonameId:int;
        /** MD5-generated Dopplr colour for this City */
        public var rgb:int;
        
        /** @return the number of trips we know about for this city, for Array.sortOn */
        public function get tripCount():int
        {
            return trips.length;
        }
        
        public function get dayCount():int
        {
            var dc:int = 0;
            for each (var trip:Trip in trips) {
                dc += trip.days;
            }
            return dc;
        }
        
        /** @return "name, countryCode" - e.g. "Amsterdam, NL" */
        public function toString():String
        {
            return this.name + ", " + this.countryCode;
        }
                
    }
}